package com.sun.controller;

import com.sun.exception.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Administrator
 */
@Controller
public class HelloController {

    @RequestMapping("/index")
    public String index(Model map) {
        // 加⼊⼀个属性，⽤来在模板中读取
        map.addAttribute("host", "http://blog.didispace.com");
        // return模板⽂件的名称，对应src/main/resources/templates/index.html
        return "index";
    }

    @RequestMapping("/hello")
    public String index() throws Exception {
        throw new Exception("发⽣错误");
    }
    @RequestMapping("/math")
    public String math(){
        int i=10/0;
        return "index";
    }

    @RequestMapping("/json")
    public String json() throws MyException {
        throw new MyException("json方式发⽣错误");
    }
}
